<?php


namespace app\adminapi\logic\user;


use app\common\model\user\Userlog;
use app\common\logic\BaseLogic;
use think\facade\Db;


/**
 * portal认证记录逻辑
 * Class UserlogLogic
 * @package app\adminapi\logic\user
 */
class UserlogLogic extends BaseLogic
{


    /**
     * @notes 添加portal认证记录
     * @param array $params
     * @return bool
     * @author gzx
     * @date 2024/07/04 16:31
     */
    public static function add(array $params): bool
    {
        Db::startTrans();
        try {
            Userlog::create([

            ]);

            Db::commit();
            return true;
        } catch (\Exception $e) {
            Db::rollback();
            self::setError($e->getMessage());
            return false;
        }
    }


    /**
     * @notes 编辑portal认证记录
     * @param array $params
     * @return bool
     * @author gzx
     * @date 2024/07/04 16:31
     */
    public static function edit(array $params): bool
    {
        Db::startTrans();
        try {
            Userlog::where('id', $params['id'])->update([

            ]);

            Db::commit();
            return true;
        } catch (\Exception $e) {
            Db::rollback();
            self::setError($e->getMessage());
            return false;
        }
    }


    /**
     * @notes 删除portal认证记录
     * @param array $params
     * @return bool
     * @author gzx
     * @date 2024/07/04 16:31
     */
    public static function delete(array $params): bool
    {
        return Userlog::destroy($params['id']);
    }


    /**
     * @notes 获取portal认证记录详情
     * @param $params
     * @return array
     * @author gzx
     * @date 2024/07/04 16:31
     */
    public static function detail($params): array
    {
        return Userlog::findOrEmpty($params['id'])->toArray();
    }
}